//package com.jhhc.utils;
//
//import com.jhhc.StormSurgeForecast.StormSurge.Uitl.TyphoonUtil;
//import com.jhhc.WaterQuality.Calculate.Forecast.CalculateController;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.beans.factory.annotation.Value;
//import org.springframework.scheduling.annotation.EnableScheduling;
//import org.springframework.scheduling.annotation.SchedulingConfigurer;
//import org.springframework.scheduling.config.ScheduledTaskRegistrar;
//import org.springframework.stereotype.Component;
//
//import java.text.SimpleDateFormat;
//import java.util.Calendar;
//import java.util.Date;
//import java.util.GregorianCalendar;
//
//@Component
//@EnableScheduling
//public class TaskUtil implements SchedulingConfigurer {
//    @Value("${task.time}")
//    String time;
//    @Autowired
//    private CalculateController calculateController;
//    @Autowired
//    private TyphoonUtil typhoonUtil;
//    // 日期格式转换
//    SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
//    Calendar calendar = new GregorianCalendar();
//    @Override
//    public void configureTasks(ScheduledTaskRegistrar taskRegistrar) {
//        // TODO: 2019/4/19 定时任务表达式，实际项目可以从配置文件、数据库等中获取
//        String cron = time;
//        System.out.println(cron);
//        taskRegistrar.addCronTask(() -> {
//            Date endDate = new Date();
//            calendar.setTime(endDate);
//            calendar.add(Calendar.DATE,  -1);
//            Date startDate = calendar.getTime();
//            try {
//                System.out.println("当前定时任务执行开始时间："+format.format(new Date()) );
//                int res = calculateController.insertOld(format.format(startDate),format.format(endDate));
//                System.out.println("数据更新数量为："+res+"条");
//                System.out.println("当前定时任务执行结束时间："+format.format(new Date()) );
//            } catch (Exception e) {
//                e.printStackTrace();
//            }
//        }, cron);
////        String cron = time;
////        System.out.println(cron);
////        taskRegistrar.addCronTask(new Runnable() {
////            @Override
////            public void run() {
////
////                try {
////                    System.out.println("当前定时任务执行开始时间："+format.format(new Date()) );
////                    int res = typhoonUtil.insertTFInfo();
////                    System.out.println("实测路径数据更新数量为："+res+"条");
////                    System.out.println("当前定时任务执行结束时间："+format.format(new Date()) );
////                } catch (Exception e) {
////                    e.printStackTrace();
////                }
////            }
////        }, cron);
//    }
//}
